import sqlite3
import time

print 'Connecting...'
conn = sqlite3.connect('d:\\programs\\odbc\\sql.txt')

cursor = conn.cursor()

print 'Cleaning...'
try:
   cursor.execute('drop table t1')
except sqlite3.OperationalError:
   pass

cursor.execute('create table t1 (id int not null primary key, msg char(100))')
conn.commit()

print 'Start to insert'
M = 1000000
N = 1
t0 = time.time()

for m in range(M):
   sqlstr = 'insert into t1 values'
   for n in range(N-1):
      sqlstr = sqlstr + " (%d, '%s')," % ( m*N+n, "M" * 100);
      #print n,

   sqlstr = sqlstr + " (%d, '%s')" % ( m*N+N-1, "M" * 100);
   #print sqlstr
   cursor.execute(sqlstr)

conn.commit()
t1 = time.time()
print
if M*N*100 > 1e6:
   print M*N/10000, 'M'
elif M*N*100 > 1e3:
   print N*M/10, 'K'
else:
   print M*N/10

print '%.3f seconds' % (t1-t0)

cursor.close()